package com.bang.exception;

import java.util.Scanner;

/*
  @author: 13813
  @date: 2024/11/25 9:29
*/
public class ExceptionDemo02 {
    public static void main(String[] args) throws FuException {
        int[] ints = new int[3];
        m1(ints, -1);
        System.out.println("A");
        Scanner scanner = new Scanner(System.in);
        scanner.nextLine();
    }

    public static void m1(int[] ints, int index) throws FuException {
        if (ints == null) {
            throw new NullPointerException("不能传空对象");
        }
        if (index < 0) {
            throw new FuException("不能为负数");
        }
        if (index > ints.length) {
            throw new ArrayIndexOutOfBoundsException("下标越界，不能访问");
        }

        System.out.println(ints[index]);
    }
}
